package models

import (
	"gorm.io/gorm"
	"strconv"
	"time"
)

type User struct {
	ID            int64     `gorm:"primaryKey;autoIncrement;comment:主键"`
	Name          string    `gorm:"type:varchar(32);not null;default:'';uniqueIndex:uni_name;comment:用户名称"`
	Password      string    `gorm:"type:varchar(255);not null;default:'';comment:密码(加密)"`
	FollowCount   int64     `gorm:"not null;default:0;comment:关注人数"`
	FollowerCount int64     `gorm:"not null;default:0;comment:粉丝人数"`
	WorkCount     int64     `gorm:"not null;default:0;comment:作品数"`
	FavoriteCount int64     `gorm:"not null;default:0;comment:点赞视频数"`
	CreatedAt     time.Time `gorm:"comment:创建时间"`
	UpdatedAt     time.Time `gorm:"autoUpdateTime;comment:更新时间"`
	DeletedAt     gorm.DeletedAt
}

func (user User) GetUid() string {
	return strconv.FormatInt(user.ID, 10)
}

func (user *User) TableName() string {
	return "user"
}
